package cn.kgm.abstractFactory;

import cn.kgm.enums.FactoryEnums;

/**
 * 工厂生成器类
 */
public class FactoryProducer {

    // 根据类型获取抽象工厂
    public static AbstractFactory getAbstractFactory(String type) {
        AbstractFactory abstractFactory = null;
        try {
            switch (FactoryEnums.getByType(type)) {
                case SHAPE:
                    abstractFactory = new ShapeFactory();
                    break;
                case COLOR:
                    abstractFactory = new ColorFactory();
                    break;
                default:
                    return abstractFactory;
            }
            return abstractFactory;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
        return null;
    }
}
